<?php

class {$className} extends f_core_Action
{ldelim}
	public function execute()
	{ldelim}	
		$documentProvider = f_document_Provider::getInstance();
				
		${$documentName}Data = $documentProvider->loadDocuments("modules_{$moduleName}/{$documentName}")->retrieveDocuments();
		
		$values['data'] = ${$documentName}Data;	
{if isset($relatedDocs) and count($relatedDocs) > 0}

		$foreignDocs = array();
		
		$xmlFileObject = f_xml_Xpath::getInstance('{$file}.xml');
		
		$properties = $xmlFileObject->fromXpath("properties/add")->getElements();
		
{foreach from=$relatedDocs key=key item=doc}
		/* @var $var f_xml_XmlElement */
		foreach($properties as $var)
		{ldelim}
			$attributes = $var->getAttributes();
			if($attributes['name'] == "{$key}")
			{ldelim}
				$foreignField = "label";
				
				if(isset($attributes['foreignField']) && $attributes['foreignField'] != "")
				{ldelim}
					$foreignField = $attributes['foreignField'];
					break;
				{rdelim}
			{rdelim}
		{rdelim}
		$foreignDocs['{$key}']['docs'] = $documentProvider->loadDocuments("{$doc.foreignDoc}")->retrieveDocuments();
		$foreignDocs['{$key}']['foreignField'] = ucfirst($foreignField);
{/foreach}
		$values['foreignDocs'] = $foreignDocs;	
{/if}		
		$this->setModel($values);
		$this->setView('success');
	{rdelim}	
	
	public function validate()
	{ldelim}
		return true;
	{rdelim}
	
	public function errorHandler()
	{ldelim}
		$this->setView('error');
	{rdelim}
{rdelim}